import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:textfield_tags/textfield_tags.dart';

import '../../../../../../../utils/colors_util.dart';
import 'logic.dart';

class Make_instructionPage extends StatelessWidget {
  final logic = Get.put(Make_instructionLogic());
  final state = Get.find<Make_instructionLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: BackButton(color: Colors.white,),
        title: Text('作批示',style: TextStyle(color: Colors.white,fontSize: 17.r),),
        centerTitle: true,
        backgroundColor: ColorsUtil.blue,
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            color: const Color(0xfff2f2f2),
                padding: EdgeInsets.all(10.r),
                child:Text(
                  '您可针对此项目进行批示调度或点评，若批示内容需要指派给具体的人员进行处理，请点击指派人员即可。',
                  style:
                  TextStyle(color: Color(0xff70b603), fontSize: 15.r),
            ),
          ),
          Container(
            margin: EdgeInsets.all(15.r),
            child: TextFieldTags(
              inputfieldBuilder: (BuildContext context, TextEditingController tec, FocusNode fn, String? error, void Function(String)? onChanged, void Function(String)? onSubmitted) {
                  return ((context, sc, tags, onTagDelete) {
                    return BrnInputText(
                      maxHeight: 200.r,
                      minHeight: 50.r,
                      minLines: 5,
                      maxLength: 500,
                      bgColor: Colors.white,
                      textString: '',
                      textInputAction: TextInputAction.newline,
                      maxHintLines: 20,
                      borderColor: Color(0xffeeeeee),
                      autoFocus: false,
                      hint: '请输入您对该项目的批示，可指派人员。',
                      padding: EdgeInsets.fromLTRB(20, 10, 20, 14),
                      onTextChange: (text) {
                        state.content = text;
                      },
                    );
                  }
                    );
              },),
            // child: BrnInputText(
            //   maxHeight: 200.r,
            //   minHeight: 50.r,
            //   minLines: 5,
            //   maxLength: 500,
            //   bgColor: Colors.white,
            //   textString: '',
            //   textInputAction: TextInputAction.newline,
            //   maxHintLines: 20,
            //   borderColor: Color(0xffeeeeee),
            //   autoFocus: false,
            //   hint: '请输入您对该项目的批示，可指派人员。',
            //   padding: EdgeInsets.fromLTRB(20, 10, 20, 14),
            //   onTextChange: (text) {
            //     state.content = text;
            //   },
            // ),
          ),
          Container(
            width: 50.r,
            height: 30.r,
            margin: EdgeInsets.only(left: 15.r),
            color: ColorsUtil.blue,
            child: Center(
              child: Text('指派',style: TextStyle(color: Colors.white,fontSize: 13.r),),
            ),
          ),
          Expanded(child: Container()),
          Row(
            children: [
              Expanded(child: GestureDetector(
                onTap: (){
                  Get.back();
                },
                child: Container(
                  height: 55.r,
                  margin: EdgeInsets.only(left: 0.5,right: 0.5),
                  color: Colors.white,
                  child: Center(child: Text('取消批示',style: TextStyle(color: Color(0xff333333),fontSize: 15.r,fontWeight: FontWeight.w500),),),
                ),
              )),
              Expanded(child: GestureDetector(
                onTap: (){
                  BrnDialogManager.showConfirmDialog(
                    Get.context!,
                    title: "提示",
                    cancel: '取消',
                    confirm: '确定',
                    message: "确定提交批示？",
                    onConfirm: () {
                      Get.back();
                      logic.save();
                    },
                    onCancel: () {
                      Get.back();
                    },
                  );
                },
                child: Container(
                  height: 55.r,
                  decoration: BoxDecoration(
                    gradient: const LinearGradient(      //渐变位置
                        begin: Alignment.centerLeft, //右上
                        end: Alignment.centerRight, //左下
                        stops: [0.0, 1.0],         //[渐变起始点, 渐变结束点]
                        //渐变颜色[始点颜色, 结束颜色]
                        colors: [Color(0xff00A9FE), Color(0xFF0173FE)]
                    ),
                    color: Colors.white,
                  ),

                  child: Center(child: Text('确认批示',style: TextStyle(color: Colors.white,fontSize: 15.r,fontWeight: FontWeight.w500),),),
                ),
              )),
            ],
          )
        ],
      ),
    );
  }
}
